#include<stdio.h>
#include<string.h>
#include <stdlib.h>
#define IN_LEN      (1024*1024ul)
int main()
{
	char data[IN_LEN];
	FILE *fp,*fp1;
	int size,n_size,n_count;
	unsigned char buf[1];
	int rc;
	
	fp=fopen("D://z//2.bin","rb");
    if(fp == NULL) 
        return -1;
    fseek(fp, 0, SEEK_END);
    size=ftell(fp);
	fread(data,sizeof(unsigned char),size,fp);
	fseek(fp, 0, SEEK_SET);
	printf("size=%d\n",size);
	n_count=size/4096;
	if(size%4096!=0)
		n_count++;
	printf("n_count=%d\n",n_count);
	for(int i=0;i<n_count;i++)
		{
			char name1[25]="D://z//r//split//";
			char name2[5];
			char name3[5]=".bin";
			n_size=0;
			itoa(i,name2,10);
			strcat(name1,name2);
			strcat(name1,name3);
			fp1=fopen(name1,"wb");
			if(i!=0)
			{
				fseek(fp, -1, SEEK_CUR);
			}
			
			while( (rc = fread(buf,sizeof(unsigned char), 1,fp)) != 0 && n_size<4096)
		    {
		    	n_size++;
		    	fwrite( buf, sizeof( unsigned char ), rc, fp1 );  
		    } 
		    fclose(fp1);
		}
	fclose(fp);
}
















